var json = null;//数据
var showCount = 10;//每页显示多少条
//初始方法
function init(jsonDate, showCount) {
	json = jsonDate;
	if ((null != showCount || "" != showCount) && showCount > 0) {
		showCount = showCount;
	}
}
$(function(){	
	var jsonData = eval(json);
	$.each(jsonData,function(i,n){
		$("#Searchresult").append("<tr><td>"+(i+1)+"</td><td>"+n.name+"</td><td>"+n.pic+"</td></tr>");  
	});
	var num_entries = $("#Searchresult tr").length;	
	$("#total").html("一共有 "+num_entries+" 条数据 每页显示"+showCount+"条");
	var initPagination = function() {
		// 创建分页
		$("#Pagination").pagination(num_entries, {
			num_edge_entries: 1, //边缘页数
			num_display_entries: 6, //主体页数
			callback: pageselectCallback,
			items_per_page:showCount //每页显示1项
		});
	 }();	 
	function pageselectCallback(page_index, jq){
		var max_elem = Math.min((page_index+1) *showCount, num_entries);		
		$("#content").html("");		
		for(var i=page_index*showCount;i<max_elem;i++){
			var new_content = $("#Searchresult tr:eq("+i+")").clone();
			$("#content").append(new_content); //装载对应分页的内容
		}
		return false;
	}
});
